package com.knife.bbs.business;

import java.util.List;

import com.knife.web.tools.DbPageList;
import com.knife.web.tools.IPageList;
import com.knife.bbs.domain.Collections;

public class CollectionsService extends DAOSupportService {
	private static CollectionsService singleton = new CollectionsService();

	public static CollectionsService getInstance() {
		return singleton;
	}

	public  Collections getCollections(String cid){
		return (Collections)(this.dao.get(Collections.class,cid));
	}
	
	public List queryCollections(String scope){
		return this.dao.query(Collections.class,scope);
	}
	
	public  Collections readCollectionsByDocUser(String docid,String ownername){		
		return (Collections)this.dao.getBy(Collections.class,"docid='"+docid+"' and ownername='"+ownername+"'",null);
	}

	public  IPageList queryUserCollections(String userName, int pageSize, int pageNo) {
		String scope="userName=?";
		java.util.Collection paras=new java.util.ArrayList();
		paras.add(userName);
		DbPageList pList = new DbPageList(Collections.class, scope,paras);
		pList.doList(pageNo, pageSize);
		return pList;
	}
	
	public  IPageList queryCollections(String scope, int pageSize, int pageNo) {
		DbPageList pList = new DbPageList(Collections.class, scope, null);
		pList.doList(pageNo, pageSize);
		return pList;
	}
}
